package day10;

import java.util.Random;

public class Demo1 {
    public static void main(String[] args){
//        String s1="qwer";
//        s1=s1+"tyu";
//        System.out.println(s1);
        StringBuilder sb=new StringBuilder("java");
        sb.append("Hello World");
        System.out.println(sb);
        //2.对象调用方法来操作字符串(适合做大量字符串修改）
        StringBuffer sb2=new StringBuffer("java");
        sb2.append("Hello World");
        System.out.println(sb2);

        sb.delete(1,sb.length()-1);
        System.out.println(sb);

        sb.insert(1,"java");
        System.out.println(sb);

        sb.deleteCharAt(sb.length()-1);
        System.out.println(sb);

        sb.replace(1,sb.length()-1,"ajav");
        System.out.println(sb);

        sb.reverse();
        System.out.println(sb);

        StringBuilder sb3=new StringBuilder();
        Random r=new Random();
        for(int i=0;i<6;i++){
            int n = r.nextInt(4)+1;
            switch (n){
                case 1:sb3.append("#");break;
                case 2:sb3.append("$");break;
                case 3:sb3.append("%");break;
                case 4:sb3.append("&");break;
            }
        }
        System.out.println(sb3);
    }

}
